home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 April / EnigmA AMIGA RUN 17 (1997)(G.R. Edizioni)(IT)[!][issue 1997-04][EAR-CD].iso / EARCD / comm / bbs / Hydra11s.lha / HBBS / Source / Doors_System / XPR / XPRD_Source / intuition.c < prev    next >
C/C++ Source or Header  |  1996-06-25  |  5KB  |  198 lines

  1.  
  2. /*
  3.     Intuition.c
  4.     -----------
  5.     Intuition functions for XPR
  6.  
  7. */
  8.  
  9. #include <proto/intuition.h>
  10. #include <proto/exec.h>
  11. #include <proto/graphics.h>
  12. #include <stdio.h>
  13. #include <string.h>
  14. #include "xproto.h"
  15. #include <intuition/intuitionbase.h>
  16.  
  17. static int fontoffset;
  18.  
  19. extern void getcdname(char*);
  20. extern short os13;
  21. extern short nowindow;
  22.  
  23. void plog(char,char*,...);
  24. // void printf(char*,...);
  25.  
  26. extern short checkcarrier,windowx,windowy;
  27. extern long chk4cd(void);
  28.  
  29. //extern void sprintf(char*,char*,);
  30.  
  31. extern struct Screen *firstscreen;
  32. extern struct IntuitionBase *IntuitionBase;
  33.  
  34. long xpr_windowsig;
  35. static struct Window *w;
  36. static struct RastPort *rp;
  37. static struct NewWindow nw={0,0,520,136,
  38.     2,1,
  39.     CLOSEWINDOW,
  40.     WINDOWDRAG|WINDOWDEPTH|WINDOWCLOSE|RMBTRAP,
  41.     0,0,0,0,0,0,0,0,0,
  42.     WBENCHSCREEN};
  43.  
  44. static void print(int x,int y,char *s)
  45. {
  46.     char buff[52];
  47.     Move(rp,8+(x<<3),15+(y<<3)+fontoffset);
  48.     sprintf(buff,"%-50.50s",s);
  49.     Text(rp,buff,50);
  50. }
  51. static void xprint(int x,int y,char *s)
  52. {
  53.     Move(rp,8+(x<<3),15+(y<<3)+fontoffset);
  54.     Text(rp,s,strlen(s));
  55. }
  56. static void nprint(int x,int y,int v)
  57. {
  58.     char buff[8];
  59.     if(v==-1) return;
  60.     sprintf(buff,"%-7ld",v);
  61.     Move(rp,8+(x<<3),15+(y<<3)+fontoffset);
  62.     Text(rp,buff,7);
  63. }
  64.  
  65. /* Opens the window */
  66. static struct TextAttr top80={"topaz.font",8,0,0};
  67. int xpr_opendisplay(void)
  68. {
  69.     if(nowindow) return(0);
  70.     if((firstscreen==(struct Screen*)-1)) firstscreen=IntuitionBase->FirstScreen;
  71.     if(firstscreen) {
  72.   nw.Type=firstscreen->Flags&SCREENTYPE;
  73.   nw.Screen=firstscreen;
  74.     }
  75.     if(windowy<0) windowy=0;
  76.     if(windowx<0) windowx=0;
  77.     if(!os13) {
  78.   struct Screen *fscr=firstscreen;
  79.  
  80.   if(!fscr) fscr=LockPubScreen(0);
  81.   if(fscr) {
  82.     fontoffset=fscr->BarHeight-10;
  83.     if(!firstscreen) UnlockPubScreen(0,fscr);
  84.   }
  85.     }
  86.  
  87.     nw.Height+=fontoffset;
  88.  
  89.     if(firstscreen) {
  90.         if(windowy+nw.Height>firstscreen->Height) windowy=firstscreen->Height-nw.Height-1;
  91.         if(windowx+520>firstscreen->Width) windowx=firstscreen->Width-521;
  92.     }
  93.     nw.TopEdge=windowy;
  94.     nw.LeftEdge=windowx;
  95.     if(!(w=OpenWindow(&nw))) return(-1);
  96.     xpr_windowsig=1<<(w->UserPort->mp_SigBit);
  97.     SetFont(rp=w->RPort,OpenFont(&top80));
  98.     SetWindowTitles(w,"XPR Transmission Status Window",
  99.   "eXternal PRotocol Driver V1.13, Written & © 1991 by Oliver Wagner");
  100.     SetDrMd(rp,JAM2);
  101.     SetAPen(rp,2);
  102.     Move(rp,8,92+fontoffset);
  103.     Draw(rp,510,92+fontoffset);
  104.     SetAPen(rp,3);
  105.     xprint(2,1,"Protocol:");
  106.     xprint(2,2,"Filename:");
  107.     xprint(2,3,"Filesize:");
  108.     xprint(3,4,"Message:");
  109.     xprint(1,5,"Last Err.:");
  110.     xprint(4,6,"Blocks:");
  111.     xprint(28,6,"Blocksize:");
  112.     xprint(5,7,"Bytes:");
  113.     xprint(31,7,"Errors:");
  114.     xprint(3,8,"Elapsed:");
  115.     xprint(29,8,"Expected:");
  116.     xprint(2,9,"Datarate:");
  117.     xprint(29,9,"Blockchk:");
  118.  
  119.     xprint(4,11,"Device:");
  120.     xprint(1,12,"BPS/Flags:");
  121.     xprint(8,13,"CD:");
  122.     xprint(6,14,"Path:");
  123.  
  124.     SetAPen(rp,1);
  125.     return(0);
  126. }
  127.  
  128. extern char *devname;
  129. extern char *tempdir;
  130. extern short devnum,checkcarrier;
  131. extern short sharedaccess,rtscts;
  132. extern int speed;
  133.  
  134. void initdisplay(void)
  135. {
  136.         char buff[256];
  137.   if(nowindow) return;
  138.   sprintf(buff,"%-.30s (%ld)",devname,(long)devnum);
  139.   xprint(12,11,buff);
  140.   sprintf(buff,"%ld %s%s",speed,(sharedaccess)?"(SHARED) ":"",(rtscts)?"(RTS/CTS)":"");
  141.   xprint(12,12,buff);
  142.         xprint(12,13,(checkcarrier)?"enabled":"disabled");
  143.   getcdname(buff);
  144.         xprint(12,14,buff);
  145. }
  146.  
  147. /* Closes the Window ;-) */
  148. void xpr_closedisplay(void)
  149. {
  150.     if(w) CloseWindow(w);
  151. }
  152.  
  153. /* Makes Displayupdate */
  154. void __saveds xpr_displayupdate(struct XPR_UPDATE *xu)
  155. {
  156.     long ud=xu->xpru_updatemask;
  157.  
  158.     if(nowindow) return;
  159.     if(ud&XPRU_PROTOCOL) print(12,1,xu->xpru_protocol);
  160.     if(ud&XPRU_FILENAME) print(12,2,xu->xpru_filename);
  161.     if(ud&XPRU_FILESIZE) nprint(12,3,xu->xpru_filesize);
  162.     if(ud&XPRU_MSG) {
  163.   plog('+',"MSG: %s\n",xu->xpru_msg);
  164.   print(12,4,xu->xpru_msg);
  165.     }
  166.     if(ud&XPRU_ERRORMSG) {
  167.   plog('+',"ERROR: %s\n",xu->xpru_errormsg);
  168.   print(12,5,xu->xpru_errormsg);
  169.     }
  170.     if(ud&XPRU_BLOCKS) nprint(12,6,xu->xpru_blocks);
  171.     if(ud&XPRU_BLOCKSIZE) nprint(39,6,xu->xpru_blocksize);
  172.     if(ud&XPRU_BYTES) nprint(12,7,xu->xpru_bytes);
  173.     if(ud&XPRU_ERRORS) nprint(39,7,xu->xpru_errors);
  174.     if(ud&XPRU_ELAPSEDTIME) xprint(12,8,xu->xpru_elapsedtime);
  175.     if(ud&XPRU_EXPECTTIME) xprint(39,8,xu->xpru_expecttime);
  176.     if(ud&XPRU_DATARATE) nprint(12,9,xu->xpru_datarate);
  177.     if(ud&XPRU_BLOCKCHECK) xprint(39,9,xu->xpru_blockcheck);
  178. }
  179.  
  180. /* Checks for User Abort */
  181. long __saveds xpr_chk4abort(void)
  182. {
  183.     struct IntuiMessage *im=0;
  184.     long ret=0;
  185.  
  186.     if(!nowindow) im=(struct IntuiMessage *)GetMsg(w->UserPort);
  187.  
  188.     if(checkcarrier) {
  189.         if(!chk4cd()) {
  190.     ret=-1;
  191.     if(!nowindow) xprint(12,13," ");
  192.   }
  193.     }
  194.     if(!im) return(ret);
  195.     ReplyMsg((struct Message *)im);
  196.     return(-1);
  197. }
  198.